
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../static/layui-v2.9.1/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <input type="hidden" id="id" name="id" value="">
    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-md3">
                <label class="layui-form-label required">所属用户</label>
            </div>
            <div class="layui-col-md9">
                <div class="layui-input-block">
                    <input type="text" id="userId" name="userId"
                           placeholder="请输入姓名" value="" class="layui-input" readonly>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-md3">
                <label class="layui-form-label required">卡号</label>
            </div>
            <div class="layui-col-md9">
                <div class="layui-input-block">
                    <input   type="text" id="idNumber" name="idNumber"
                           placeholder="请输入证件号码" value="" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-md3">
                <label class="layui-form-label required">银行卡类型</label>
            </div>
            <div class="layui-col-md9">
                <div class="layui-input-block">
                    <select id="cardType" name="cardType" lay-filter="cardTypeSelect" readoonly>
                        <option value="">请选择卡类型</option>
                        <option value="1">借记卡</option>
                        <option value="2">信用卡</option>
                    </select>
                </div>
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-md3">
                <label class="layui-form-label required">开卡日期</label>
            </div>
            <div class="layui-col-md3">
                <div class="layui-input-block">
                    <input type="datetime-local" id="beginDate" name="beginDate"
                           value="" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-md3">
                <label class="layui-form-label required">额度</label>
            </div>
            <div class="layui-col-md9">
                <div class="layui-input-block">
                    <input type="text" id="total" name="total"
                           placeholder="请输入额度" value="" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认开户</button>
        </div>
    </div>
</div>
<script src="../static/layui-v2.9.1/layui/layui.js" charset="utf-8"></script>
<script>

    window.onload=function (){
        var randomNumber = generateRandom12Digits();
        console.log(randomNumber)
        document.getElementById('idNumber').value = randomNumber;
    }

    document.addEventListener('DOMContentLoaded', function() {
        var randomNumber = generateRandom12Digits();
        document.getElementById('idNumber').value = randomNumber;
    });

    function generateRandom12Digits() {
        var min = 100000000000; // 最小的12位数
        var max = 999999999999; // 最大的12位数
        var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
        return randomNumber.toString(); // 转换成字符串以确保是12位数字
    }

    layui.use(['form'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            console.log("data--->>>", data);
            var jsData = data.field;
            $.ajax({
                url: "/cardReviewMessageUpdate",
                type: "post",
                data: jsData,
                success: function (result) {
                    if (result.code == 0) {
                        layer.alert("更新成功", {icon: 6}, function () {
                            //关闭当前frame
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            // 可以对父窗口进行刷新
                            parent.location.reload();
                        });
                    } else {

                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                        layer.msg("更新成功")
                    }
                }
            })

            return false;
        });
    });

</script>
</body>
</html>
